﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Chinaer.Model.Entities
{
    /// <summary>
    /// 实体基类 定义了所有基类基本都必须要有的六个元素 是否启用 是否删除 创建时间 创建人 以及修改时间 修改人
    /// </summary>
    [DataContract]
    public class Model_Base
    {
        private Chinaer.Core.BaseCore.LoginStatus _loginStatusEnum = Chinaer.Core.BaseCore.LoginStatus.False;
        /// <summary>
        /// 登录状态
        /// </summary>
        [NotMapped]
        public Chinaer.Core.BaseCore.LoginStatus LoginStatusEnum
        {
            get
            {
                return _loginStatusEnum;
            }
            set
            {
                _loginStatusEnum = value;
            }
        }

        /// <summary>
        /// 用于进行并发性控制的字段
        /// </summary>
        //[ConcurrencyCheck]
        //[Timestamp]
        //public byte[] RowVersion { get; set; }

        private bool _isUse = true;
        private DateTime? _createTime = DateTime.Now;
        private bool _isDelete = false;
        private DateTime? _modifyTime = DateTime.Now;
        /// <summary>
        /// 创建人编号 非必填
        /// </summary>
        [StringLength(50)]
        public string CreateUserID { get; set; }
        /// <summary>
        /// 非必填  创建时间
        /// </summary>
        public DateTime? CreateTime
        {
            get
            {
                if (_createTime == DateTime.MinValue)
                {
                    _createTime = DateTime.Now;
                }
                return _createTime;
            }
            set
            {
                _createTime = value;
            }
        }
        /// <summary>
        /// 修改人  非必填
        /// </summary>
        [StringLength(50)]
        public string ModifyUserID { get; set; }
        /// <summary>
        /// 修改时间 非必填
        /// </summary>
        public DateTime? ModifyTime
        {
            get
            {
                if (_modifyTime == DateTime.MinValue)
                {
                    _modifyTime = DateTime.Now;
                }
                return _modifyTime;
            }
            set { _modifyTime = value; }
        }
        /// <summary>
        /// 是否启用 非必填 默认为true
        /// </summary>
        public bool IsUse
        {
            get
            {
                return _isUse;
            }
            set
            {
                _isUse = value;
            }
        }
        /// <summary>
        /// 是否删除 加入一个删除标志 非必填默认为false
        /// </summary>
        public bool IsDelete
        {
            get
            {
                return _isDelete;
            }
            set
            {
                _isDelete = value;
            }
        }
        public DateTime SJC
        {
            get
            {
                return DateTime.Now;
            }
        }
    }
}
